// $(function () {
//     $("#org").jOrgChart({
//         chartElement : '#chart',
//         dragAndDrop  : false
//     });
//
//     $('#chart').on('dblclick',function () {
//
//         var sblId = $(this).prev().attr('libId');
//         var orgId = $(this).prev().attr('orgId');
//         var url = baseUrl+'school_book/addTotalGroup/'+sblId;
//         if(orgId != undefined){
//             url +='/'+orgId;
//         }
//         window.top.xhTop.showModal({
//             title:'快捷创建',
//             content: '<iframe src="'+url+'"  style="width: 100%;;border-style: none;padding: 0px;height: 320px"  scrolling="yes"   ></iframe>',
//             button:'提交',
//             backClose: false,
//             size:'lg',
//             width:1000
//         })
//     });
// });
$(function () {
   obj.init();
});
var obj = new function () {
    'use strict';
    return {
        iSBLId:null,
        dataGrid:null,
        init:function () {
            this.iSBLId = xhTool.getQuery('iSBLId');
            this.dataGrid = new xhDataGrid($('#list'), 'school_book/getGroup', {iSBLId:this.iSBLId});
            this.dataGrid.parseToolbar().init().activeButton([''], []);
            this.listener();
            this.funObj().bindDgEvent();
        },
        listener:function () {
            var $this = this;
            //快捷创建
            $('#bt_list_shortcut').click(function () {
                $this.funObj().addAllForm();
            });
            //搜索
            $('#bt_list_search').click(function () {
                $this.funObj().search();
            });
        },
        funObj:function () {
            var $this = this;
            return {
                addAllForm:function () {
                    window.top.xhTop.showModal({
                        title:'快捷创建',
                        content: '<iframe src="'+baseUrl+'school_book/addTotalGroup/'+$this.iSBLId+'"  style="width: 100%;;border-style: none;padding: 0px;height: 320px"  scrolling="yes"   ></iframe>',
                        button:'提交',
                        backClose: false,
                        size:'lg',
                        width:1000
                    });
                },
                search:function () {
                    var key     = xhExtra.getValue($('#list_search'));
                    var subject = xhExtra.getValue($('#list_subject'));
                    var grade   = xhExtra.getValue($('#list_grade'));
                    $this.dataGrid.reload({iSBLId : $this.iSBLId, key : key, subject : subject, grade : grade });
                },
                bindDgEvent:function() {
                    $this.dataGrid.onLoadSuccess = function () {
                        $this.dataGrid.mergeCells(['iChargeAll','iGrade']);
                    };
                    $this.dataGrid.onDblClickRow = function () {
                        window.top.xhTop.showModal({
                            title:'快捷创建',
                            content: '<iframe src="'+baseUrl+'school_book/addTotalGroup/'+$this.iSBLId+'"  style="width: 100%;;border-style: none;padding: 0px;height: 320px"  scrolling="yes"   ></iframe>',
                            button:'提交',
                            backClose: false,
                            size:'lg',
                            width:1000
                        });
                    }
                }
            }
        }

    }
};